package com.orchard.xpz.utils;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

/**
 * @TaskCode:
 * @description: 分页封装工具
 * @author: minshuai.chen
 * @create: 2022/4/13 14:27
 **/
@Data
@NoArgsConstructor
public class PageResultData<T> {

    private List<T> rows;

//    private PageInfo pageInfo = new PageInfo();

//    public PageResultData(List<T> rows) {
//        com.github.pagehelper.PageInfo page_helper = new com.github.pagehelper.PageInfo(rows);
//
//        this.rows = page_helper.getList();
//
//        pageInfo.setRecordCounts((int)page_helper.getTotal());
//        pageInfo.setSize(page_helper.getSize());
//        pageInfo.setEndRow(page_helper.getEndRow());
//        pageInfo.setFirstPage(page_helper.isIsFirstPage());
//        pageInfo.setLastPage(page_helper.isIsLastPage());
//        pageInfo.setNextPage(page_helper.getNextPage());
//        pageInfo.setPageNum(page_helper.getPageNum());
//        pageInfo.setPages(page_helper.getPages());
//        pageInfo.setPageSize(page_helper.getPageSize());
//        pageInfo.setPrePage(page_helper.getPrePage());
//        pageInfo.setStartRow(page_helper.getStartRow());
//    }

    public PageResultData(List<T> rows,int pageNum, int  pageSize) {
        com.github.pagehelper.PageInfo page_helper = new com.github.pagehelper.PageInfo(rows);
        this.rows = page_helper.getList();
        this.setPageCount(page_helper.getPages());
        this.setRowCount(page_helper.getTotal());
        this.pageSize = pageSize;
        this.pageStart = pageNum;
    }

    private Integer pageCount;

    private Integer pageSize;

    private Integer pageStart;

    private Long rowCount;


}
